from core.room import Room
from core.basehandler import BaseHandler
from core.action import Action

class Cliff(Room):
    
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        self.locked = True
        self.add_action(Jump)
        
    
    # return description of room.
    def get_description(self):
        if self.locked:
            return '''The road ends...There is a cliff that you can not see the bottom, what can you do?
            Hint: On the potion bottle writes "If you die in dream, you wake up in reality." '''    
            
    # return image of room
    def get_image(self):
        return 'Abyss.jpg'

class CliffHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Cliff

# define actions for this room
class Jump(Action):
    def __init__(self):
        Action.__init__(self, "jump")
        self.immortal=False
        
    def get_description(self):
        return "Jump off"
    
    # return id of room to enter when action is complete
    def do_action(self,game,room,request):
        if room.locked:
            self.immortal = False
        else:
            self.immortal = True
    
    def get_destination(self):
        if self.immortal:
            return "live"
        else:
            return "death"
     
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
class CliffToLive(Action):
    def __init__(self):
        Action.__init__(self, "cliff_to_live")
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Jump"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'live'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

